#ifndef VECTOR2D_
#define VECTOR2D_

class Vector2D
{
public:
	float x;
	float y;
	
	Vector2D();
	Vector2D(float x0, float y0);
	
	// Addition/subtraction
	Vector2D operator+(Vector2D other) const;
	//friend Vector3D operator+(Vector3D a, Vector3D &b);
	Vector2D operator-(Vector2D other);

	//Multiplication by number
	Vector2D operator*(float k);
	friend Vector2D operator*(float k, Vector2D &other);

	//Inner product
	float operator*(Vector2D other);
	//Cross product
	Vector2D operator%(Vector2D other);
	
	//Normalization
	Vector2D operator!();
    //Distance (for 3D points)
	float operator|(Vector2D other);
	//Square Distance (for 3D points) (sometimes helps reduce many SQRTs)
	float operator ||(Vector2D other);

	bool operator ==(Vector2D other);
	float operator /(Vector2D other);
	Vector2D operator/(float k);
	Vector2D& operator *=(float k);

	float Magnitude(void);


	void add(Vector2D other);
	void subtract(Vector2D other);
	void negate();

	void mul(float k);
	float dot(Vector2D other);
	void cross(Vector2D one, Vector2D other);
	float AngleDirection(Vector2D other);
	float dist(Vector2D other);
	float sqdist(Vector2D other);
	
	static float PointToLineDistance(Vector2D &point, Vector2D &endPoint1, Vector2D &endPoint2);
	static Vector2D ClosestPointOnSegment(Vector2D &a, Vector2D &b, Vector2D &c);
	static bool SegmentsIntersect(Vector2D a, Vector2D b, Vector2D c, Vector2D d);
};
#endif /*VECTOR2D_*/
